home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 2.iso / dist / fw_gimp.idb / usr / freeware / share / gimp / 1.2 / scripts / xach-effect.scm.z / xach-effect.scm
Text File  |  2002-07-08  |  5KB  |  135 lines

  1.  
  2.  
  3. ; The GIMP -- an image manipulation program
  4. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  5. ; xach effect script
  6. ; Copyright (c) 1997 Adrian Likins
  7. ; aklikins@eos.ncsu.edu
  8. ;
  9. ; based on a idea by Xach Beane <xach@mint.net>
  10. ;
  11. ;
  12. ; This program is free software; you can redistribute it and/or modify
  13. ; it under the terms of the GNU General Public License as published by
  14. ; the Free Software Foundation; either version 2 of the License, or
  15. ; (at your option) any later version.
  16. ; This program is distributed in the hope that it will be useful,
  17. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. ; GNU General Public License for more details.
  20. ; You should have received a copy of the GNU General Public License
  21. ; along with this program; if not, write to the Free Software
  22. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23.  
  24.  
  25. (define (script-fu-xach-effect image
  26.                    drawable
  27.                    hl-offset-x
  28.                    hl-offset-y
  29.                    hl-color
  30.                    hl-opacity-comp
  31.                    ds-color
  32.                    ds-opacity
  33.                    ds-blur
  34.                    ds-offset-x
  35.                    ds-offset-y
  36.                    keep-selection)
  37.   (let* ((ds-blur (max ds-blur 0))
  38.      (ds-opacity (min ds-opacity 100))
  39.      (ds-opacity (max ds-opacity 0))
  40.      (type (car (gimp-drawable-type-with-alpha drawable)))
  41.      (image-width (car (gimp-image-width image)))
  42.      (hl-opacity (list hl-opacity-comp hl-opacity-comp hl-opacity-comp))
  43.      (image-height (car (gimp-image-height image)))
  44.      (old-bg (car (gimp-palette-get-background))))
  45.  
  46.     (gimp-undo-push-group-start image)
  47.     (gimp-layer-add-alpha drawable)
  48.     
  49.     
  50.     (if (= (car (gimp-selection-is-empty image)) TRUE)
  51.     (begin
  52.       (gimp-selection-layer-alpha drawable)
  53.       (set! active-selection (car (gimp-selection-save image)))
  54.       (set! from-selection FALSE))
  55.     (begin
  56.       (set! from-selection TRUE)
  57.       (set! active-selection (car (gimp-selection-save image)))))
  58.  
  59.     (set! hl-layer (car (gimp-layer-new image image-width image-height type "Highlight" 100 NORMAL)))
  60.     (gimp-image-add-layer image hl-layer -1)
  61.  
  62.     (gimp-selection-none image)
  63.     (gimp-edit-clear hl-layer)
  64.     (gimp-selection-load active-selection)
  65.     
  66.     (gimp-palette-set-background hl-color)
  67.     (gimp-edit-fill hl-layer BG-IMAGE-FILL)
  68.     (gimp-selection-translate image hl-offset-x hl-offset-y)
  69.     (gimp-edit-fill hl-layer BG-IMAGE-FILL)
  70.     (gimp-selection-none image)
  71.     (gimp-selection-load active-selection)
  72.     
  73.     (set! mask (car (gimp-layer-create-mask hl-layer WHITE-MASK)))
  74.     (gimp-image-add-layer-mask image hl-layer mask)
  75.     
  76.     (gimp-palette-set-background hl-opacity)
  77.     (gimp-edit-fill mask BG-IMAGE-FILL)
  78.  
  79.     (set! shadow-layer (car (gimp-layer-new image
  80.                         image-width
  81.                         image-height
  82.                         type
  83.                         "Shadow"
  84.                         ds-opacity
  85.                         NORMAL)))
  86.     (gimp-image-add-layer image shadow-layer -1)
  87.     (gimp-selection-none image)
  88.     (gimp-edit-clear shadow-layer)
  89.     (gimp-selection-load active-selection)
  90.     (gimp-selection-translate image ds-offset-x ds-offset-y)
  91.     (gimp-palette-set-background ds-color)
  92.     (gimp-edit-fill shadow-layer BG-IMAGE-FILL)
  93.     (gimp-selection-none image)
  94.     (plug-in-gauss-rle 1 image shadow-layer ds-blur TRUE TRUE)
  95.     (gimp-selection-load active-selection)
  96.     (gimp-edit-clear shadow-layer)
  97.     (gimp-image-lower-layer image shadow-layer)
  98.  
  99.  
  100.     (gimp-palette-set-background old-bg)
  101.  
  102.     (if (= keep-selection FALSE)
  103.     (gimp-selection-none image))
  104.  
  105.     (gimp-image-set-active-layer image drawable)
  106.     (gimp-image-remove-channel image active-selection)
  107.     (gimp-undo-push-group-end image)
  108.     (gimp-displays-flush)))
  109.  
  110. (script-fu-register "script-fu-xach-effect"
  111.             _"<Image>/Script-Fu/Shadow/Xach-Effect..."
  112.             "Add a subtle translucent 3-d effect to the current selection or alpha channel"
  113.             "Adrian Likins <adrian@gimp.org>"
  114.             "Adrian Likins"
  115.             "9/28/97"
  116.             "RGB* GRAY*"
  117.             SF-IMAGE "Image" 0
  118.             SF-DRAWABLE "Drawable" 0
  119.             SF-ADJUSTMENT _"Highlight X Offset" '(-1 -100 100 1 10 0 1)
  120.             SF-ADJUSTMENT _"Highlight Y Offset" '(-1 -100 100 1 10 0 1)
  121.             SF-COLOR      _"Highlight Color" '(255 255 255)
  122.             SF-ADJUSTMENT _"Highlight Opacity" '(66 0 255 1 10 0 0)
  123.             SF-COLOR      _"Drop Shadow Color" '(0 0 0)
  124.             SF-ADJUSTMENT _"Drop Shadow Opacity" '(100 0 100 1 10 0 0)
  125.             SF-ADJUSTMENT _"Drop Shadow Blur Radius" '(12 0 255 1 10 0 1)
  126.             SF-ADJUSTMENT _"Drop Shadow X Offset" '(5 0 255 1 10 0 1)
  127.             SF-ADJUSTMENT _"Drop Shadow Y Offset" '(5 0 255 1 10 0 1)
  128.             SF-TOGGLE     _"Keep Selection" TRUE)
  129.  
  130.  
  131.  
  132.